package csen;

import java.util.*;

public class MainClass {

	public static void main(String[] args) {

		try {
			CarStoreLog csl = new CarStoreLog("CarStoreLog.log");
			CarStore cs = new CarStore();
			cs.registerObserver(csl);

			Car car = new CarFactory().getCar("coupe", "Audi", Color.Black,
					FuelType.Gasoline, 11450);
			Car car2 = new CarFactory().getCar("sedan", "BMW", Color.Blue,
					FuelType.Diesel, 24999);
			Car car3 = new CarFactory().getCar("truck", "Hummer", Color.Yellow,
					FuelType.Diesel, 17500);
			
			cs.addCar(car);
			cs.addCar(car2);
			cs.addCar(car3);
			
			String id = cs.createOrder(car);
			System.out.println(cs.isOrdered(id)); //true
			cs.approveOrder(id);
			System.out.println(cs.isOrdered(id)); //false
			
			String id3 = cs.createOrder(car3);
			System.out.println(cs.isOrdered(id3)); //true
			cs.cancelOrder(id3);
			System.out.println(cs.isOrdered(id3)); //false
			
			ArrayList<Car> foundCars = cs.search("BMW");
			for (Car c : foundCars) {
				System.out.println(c.toString());
			}

		} catch (IllegalArgumentException e) {
			e.printStackTrace();
		}
	}

}
